const moment = require("moment")
const dateFormat = 'YYYY-MM-DD';
const fullFormat = 'YYYY-MM-DD HH:mm:ss';


const getTimeZone = function () {
    let d = new Date();
    let n = d.getTimezoneOffset();
    let tz = n / -60;
    let tzStr = '';
    if (tz >= 0) {
        tz = tz < 10 ? '0' + tz : tz;
        tzStr = '+' + tz + ':00';
    } else {
        tz = tz > -10 ? '-0' + (-tz) : tz;
        tzStr = tz + ':00';
    }
    return tzStr;
};

//获取当前时间(为结束时间)
const getCurrentDate = function () {
    return moment().format(fullFormat);
}

//获取当前时间的的前一天(作为起始时间)
const getOneDay = function () {
    return moment().subtract(1, "days").format(fullFormat);
}

module.exports = {getTimeZone, getCurrentDate,getOneDay};